package com.zoz.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.zoz.service.DatabaseService;
import com.zoz.vo.DatabaseVo;

/**
 * 数据库操作控制层 
 *@author zhuhg
 *@date 2020年6月4日 下午3:46:59
 */
@Controller
@RequestMapping(value = {"/code/factory/service/v1/database/"}, produces = {"application/json;charset=utf-8"})
public class DatabaseController {

	private static final Logger logger = LoggerFactory.getLogger(DatabaseController.class);

    @Autowired
    private DatabaseService databaseService;

    @GetMapping(value = {"/queryAllDatabase"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String queryAllDatabase() {
        // 查询结果返回前端
        return databaseService.queryAllDatabase();
    }
    @GetMapping(value = {"/queryAllTables"}, produces = {"application/json;charset=utf-8"})
	@ResponseBody
	public String queryAllTables(DatabaseVo vo) {
    	String param = JSON.toJSONString(vo);
		logger.info("查询 所有表 参数 -> {}",param);
		// 查询结果返回前端
		return databaseService.queryAllTables(vo);
	}
    @GetMapping(value = {"/queryAllTableColumns"}, produces = {"application/json;charset=utf-8"})
	@ResponseBody
	public String queryAllTableColumns(DatabaseVo vo) {
    	String param = JSON.toJSONString(vo);
		logger.info("查询 列属性 参数 -> {}",param);
		// 查询结果返回前端
		return databaseService.queryAllTableColumns(vo);
	}
}
